package com.lb.pdm.controller;


import com.lb.pdm.common.result.GraceJSONResult;
import com.lb.pdm.entity.bo.FloatingPopulationBO;
import com.lb.pdm.entity.vo.FloatingPopulationVO;
import com.lb.pdm.service.FloatingPopulationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Title: FloatingPopulationController
 * @Author Wood
 * @Package com.lb.pdm.controller
 * @Date 2025/11/4 9:09
 * @description:
 */
@RestController
@RequestMapping("/floatingPopulation")
public class FloatingPopulationController {
    @Autowired
    private FloatingPopulationService floatingPopulationService;

    @PostMapping("/input")
    public GraceJSONResult input(@RequestBody FloatingPopulationBO floatingPopulationBO, @RequestHeader("token") String token) {
        return floatingPopulationService.inputFloatingPopulation(floatingPopulationBO, token);
    }

    @GetMapping("/query")
    public GraceJSONResult query(@RequestParam(value = "name", required = false) String name,
                                 @RequestParam(value = "idCard", required = false) String idCard,
                                 @RequestParam(value = "residenceType", required = false) Byte residenceType,
                                 @RequestParam("pageNum") Integer pageNum,
                                 @RequestParam("pageSize") Integer pageSize) {
        List<FloatingPopulationVO> floatingPopulationVOS = floatingPopulationService.query(name, idCard, residenceType, pageNum, pageSize);
        return GraceJSONResult.ok(floatingPopulationVOS);
    }
}
